import { IsInt, IsNotEmpty, IsOptional, IsString, MaxLength, Min } from 'class-validator'

// 分类新增与修改 DTO，中文注释，参数校验
export class CreateCategoryDto {
  @IsInt()
  @IsOptional()
  parentId?: number = 0

  @IsString()
  @IsNotEmpty()
  @MaxLength(50)
  name: string

  @IsString()
  @IsOptional()
  @MaxLength(255)
  icon?: string

  @IsInt()
  @IsOptional()
  @Min(0)
  sort?: number = 0

  @IsInt()
  @IsOptional()
  status?: number = 1
}

export class UpdateCategoryDto extends CreateCategoryDto {
  @IsInt()
  @Min(1)
  categoryId: number
}
